package com.ouken.com;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import com.gen.tool.SoundPlayer;
import com.ouken.asynTask.AsynResetpwd;
import com.ouken.asynTask.AsynSendCode;
//import com.ouken.tool.MplayerTool;
import com.ouken.tool.MyApp;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.media.AudioManager;
import android.media.SoundPool;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

public class ForgetPwdActivity extends Activity {
	private MyApp appState;
	private SharedPreferences userInfo;
	private	RelativeLayout RL_bg;
	private ImageButton imagebutton_resetpasswd ;
	private ImageButton imagebutton_back ;
	private EditText et_forgetpwd_email;
	//private MplayerTool mplayerTool ;
	private EditText code;
	private ImageButton sendcode;
	private Context context;
	
	
	
	private void initView(){
		userInfo = getSharedPreferences("user_info", 0);
		appState = ((MyApp)getApplicationContext());
		//appState.setMusic(userInfo.getString("MUSIC", "ON").equals("ON"));
		appState.addActivity(ForgetPwdActivity.this);
	   
		RL_bg = (RelativeLayout)findViewById(R.id.relativelayout_forgetpwd_bg);
        imagebutton_resetpasswd = (ImageButton)findViewById(R.id.forgetpwdActivity_ib_resetpassword);
        imagebutton_back = (ImageButton)findViewById(R.id.forgetpwdActivity_ib_back);
        et_forgetpwd_email = (EditText)findViewById(R.id.forgetpwdActivity_et_email);
		code = (EditText)findViewById(R.id.forgetpwdActivity_et_code);
		sendcode = (ImageButton)findViewById(R.id.forgetpwdActivity_ib_sendcode);
        
		
		context = ForgetPwdActivity.this;
        //mplayerTool = new MplayerTool(ForgetPwdActivity.this);
	}
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.forgetpwd);
        initView();
        
		
        
        RL_bg.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(ForgetPwdActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
			}
		});
        
        imagebutton_resetpasswd.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				SoundPlayer.playSound(R.raw.keypress_common);
				//mplayerTool.playButtonPressed(ForgetPwdActivity.this);
				
				new AsynResetpwd(context, appState, sendcode,code,et_forgetpwd_email).execute();
				
				
				
				
			}
		});
        
        sendcode.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				new AsynSendCode(context, appState, et_forgetpwd_email.getText().toString(),  code.getText().toString()).execute();
			}
		});
        
        imagebutton_back.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				SoundPlayer.playSound(R.raw.keypress_common);
				//mplayerTool.playButtonPressed(ForgetPwdActivity.this);
				ForgetPwdActivity.this.finish();
			}
		});
    }

}
